﻿using UnityEngine;
using System.Collections;

public class CameraControllerBeta: MonoBehaviour {

	public Camera playerCamera;
	public string playername = "Player";
	public float camHeight = 7f;
	public float camSpeed = 1.0f;
	Vector3 newPos = new Vector3(0,0,0);
	// Use this for initialization
	void Start () {
		gameObject.transform.parent.gameObject.transform.renderer.material.color = Color.red;
		/*
		foreach(Transform child in gameObject.transform.parent.transform){
			foreach(Component comp in child.gameObject.GetComponents<BoxCollider>()){
				Debug.Log(comp.name);
				if(comp.name == "Cube"){
					Destroy(child.gameObject);
				}
			}
		}
		*/
	}

	void Awake(){		
		newPos = playerCamera.transform.position;
	}
	
	// Update is called once per frame
	void Update () {
	}

	void OnTriggerEnter(Collider collider){
		gameObject.transform.parent.gameObject.transform.renderer.material.color = Color.blue;
		if(collider.gameObject.name == playername){
			newPos = new Vector3(transform.position.x,camHeight,transform.position.z);
			playerCamera.transform.position = newPos;
		}
	}

	void OnTriggerStay(Collider collider){

	}

	void OnTriggerExit(Collider collider){
		gameObject.transform.parent.gameObject.transform.renderer.material.color = Color.green;
	}


}
